package com.huawei.appgallery.jsonkit.impl.db;

import android.content.ContentValues;
import android.database.Cursor;
import android.text.TextUtils;
import com.huawei.appgallery.jsonkit.api.JsonBean;
import java.lang.reflect.Field;
import o.blw;
import o.bmc;
import o.clq;
import org.json.JSONObject;

public class JsonBeanProcess implements bmc {
    public String ˊ() {
        return "TEXT";
    }

    public void ˋ(ContentValues contentValues, String str, Object obj) {
        ˋ(contentValues, str, (JsonBean) obj);
    }

    public void ˎ(blw o_blw, Field field, Cursor cursor, int i) {
        ˎ(o_blw, cursor, field, i);
    }

    private void ˋ(ContentValues contentValues, String str, JsonBean jsonBean) {
        String str2 = "";
        try {
            str2 = jsonBean.toJson();
        } catch (Throwable e) {
            clq.ˎ.ˊ("JsonBeanProcess", "jsonBeanToContentValue can not toJson: ", e);
        }
        contentValues.put(str, str2);
    }

    private static void ˎ(blw o_blw, Cursor cursor, Field field, int i) {
        try {
            Object string = cursor.getString(i);
            if (!TextUtils.isEmpty(string)) {
                JSONObject jSONObject = new JSONObject(string);
                JsonBean jsonBean = (JsonBean) field.getType().newInstance();
                jsonBean.fromJson(jSONObject);
                field.set(o_blw, jsonBean);
            }
        } catch (Throwable e) {
            clq.ˎ.ˊ("JsonBeanProcess", "getJsonBeanValue can not paser json: ", e);
        } catch (Throwable e2) {
            clq.ˎ.ˊ("JsonBeanProcess", "getJsonBeanValue can not instance: ", e2);
        } catch (Throwable e22) {
            clq.ˎ.ˊ("JsonBeanProcess", "getJsonBeanValue can not find class: ", e22);
        } catch (Throwable e222) {
            clq.ˎ.ˊ("JsonBeanProcess", "getJsonBeanValue can not access class: ", e222);
        }
    }
}
